using System.Collections;
using UnityEngine;

namespace GameToolkit.UI
{
    public interface IFilter
    {
        bool OnFilter(object target);
    }
    
    /// <summary>
    /// 数据源
    /// </summary>
    public interface IDataSource
    {
        void SetData(object data);
        object GetData();
        void ApplyUpdate();
    }

    public interface IDataSourceHandler
    {
        void OnRefreshData();
    }

    public interface IDataList : IEnumerable
    {
        int DataCount { get; }
        void ClearData();
        void BindData(IEnumerable iter);
        //void BindData<T>(IEnumerable<T> iter) where T : class;
        void AddData(object data);// where T : class;
        void RemoveData(object data);// where T : class;
        void RemoveAt(int index);
        object GetData(int index);
        T GetDataComponent<T>(int index) where T : class;
        GameObject GetDataInstance(int index);
        void UpdateData(object data);
    }

    public interface IFilterableCollection
    {
        IFilter DataFilter { get; set; }
        void ForceFilterImmediate();
    }

    public interface IComparableCollection
    {
        IComparer DataComparer { get; set; }
        void ForceSortImmediate();
    }
}